home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Samples / Driver Samples / Video samples / GDX 950717 / GDX / GraphicsPriv.h < prev   
Encoding:
C/C++ Source or Header  |  1996-08-20  |  11.8 KB  |  272 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        GraphicsPriv.h
  3.  
  4.     Contains:    This file is private to GDX items.  It contains declarations for items that
  5.                 are strictly internal to the GDX model.
  6.  
  7.     Written by:    Sean Williams, Kevin Williams
  8.  
  9.     Copyright:    © 1994-1995 by Apple Computer, Inc., all rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <1>     4/15/95    SW        First Checked In
  14.  
  15. */
  16.  
  17. #ifndef __GRAPHICSPRIV__
  18. #define __GRAPHICSPRIV__
  19.  
  20. #include <Types.h>
  21. #include <Video.h>
  22.  
  23.  
  24. // When writing to hardware in the C world, register address need to be declared
  25. // as volatile.  Why?  Often a register is written to, and then read immediately.
  26. // C, optimizing away programmers intentions, will not do the read.  
  27. typedef volatile  UInt8        HWRegister8Bit;
  28. typedef volatile  UInt16    HWRegister16Bit;
  29. typedef volatile  UInt32    HWRegister32Bit;
  30.  
  31.  
  32.  
  33. //
  34. // GDXErr
  35. //    These error codes are private to the GDX model, and are not seen by any of the
  36. //    Graphics driver clients.  They are used for debugging purposes, so the driver
  37. //    writer will have more resolution than is provided by 'controlErr' or 'statusErr'.
  38. //
  39. typedef SInt32 GDXErr;
  40. enum
  41. {
  42.     kGDXErrUnknownError = -4096,                // Sloppy programming if ever seen
  43.  
  44.     kGDXErrNoError = 0,                
  45.     kGDXErrInvalidParameters = -1,                // Invalid parameters were provided
  46.     
  47.     kGDXErrDriverAlreadyOpen = -2,                // Driver is already open and got another open command
  48.     kGDXErrDriverAlreadyClosed = -3,            // Driver is closed and got another close command
  49.     kGDXErrRequestedModeNotPossible = -4,        // Invalid depth mode and/or display page requested
  50.     kGDXErrDisplayModeIDUnsupported = -5,        // Frame buffer cannot support requested DisplayModeID
  51.     kGDXErrMonitorUnsupported = -6,                // The connected monitor type is not supported
  52.     kGDXErrDepthModeUnsupported = -7,            // Frame buffer cannot support requested DepthMode
  53.     kGDXErrInvalidForIndexedDevice = -8,        // An invalid operation was attempted for a indexed device
  54.     kGDXErrInvalidForDirectDevice = -9,            // An invalid operation was attempted for a direct device
  55.     kGDXErrUnableToMapDepthModeToBPP = -10,        // Cannot relative pixel depth to absolute pixel depth
  56.     kGDXErrInvalidColorSpecTable = -11,            // Client supplied invalid ColorSpec table
  57.     kGDXErrUnableToAllocateColorSpecTable = -12,// Unable to allocate memory for a ColorSpec table
  58.     kGDXErrUnableToAllocateGammaTable = -13,    // Unable to allocate memory for a gamma table
  59.     kGDXErrUnableToAllocateCoreData = -14,        // Unable to allocate memory for a Core data
  60.     kGDXErrUnableToAllocateHALData = -15,        // Unable to allocate memory for a HAL data
  61.     kGDXErrUnableToAllocateData = -16,            // Unable to allocate misc data
  62.     kGDXErrInvalidGammaTable = -17,                // Client supplied an invalid gamma table.
  63.     kGDXErrInvalidResolutionForMonitor = -18,    // Monitor doesn't support requested resolution
  64.     kGDXErrNoConnectedMonitor = -19,            // No monitor connected
  65.     kGDXErrOSSPropertyNameLengthTooLong = -20,    // PropertyName exceeded the maximum length
  66.     kGDXErrOSSPropertyStorageInvalid = -21,        // OSS PropertyStorage invalid
  67.     kGDXErrOSSUnableToSavePropertyStorage= -22,    // OSS PropertyStorage could not be saved
  68.     kGDXErrOSSNoProperyNameAndValue = -23,        // Unable to find the propertyName and propertyValue
  69.     kGDXErrOSSUnableToGetPropertyValue = -24,    // Property exists but unable to Get the propertyValue
  70.     kGDXErrOSSPropertySizeExceedsBuffer = -25,    // PropertySize exceeds the buffer size
  71.     kGDXErrOSSUnexpectedPropertySize = -26,        // PropertySize didn't match.  propetyValue is bad
  72.     kGDXErrOSSUnableToSetPropertyValue = -27,    // Unable to set a propertyValue for a property we know exists
  73.     kGDXErrOSSUnableToCreateProperty = -28,        // Unable to create a property
  74.     kGDXErrOSSUknownMappedDisplayModeID = -29,    // Mapped displayModeID (grpf) is unknown
  75.     kGDXErrOSSUknownMappedDepthMode = -30,        // Mapped depthMode (grpf) is unknown
  76.     kGDXErrOSSUknownMappedDisplayCode = -31,    // Mapped displayCode (grpf) is unknown
  77.     kGDXErrOSSNoISTProperty = -32,                // No kISTPropertyName for the RegEntryID
  78.     kGDXErrOSSNoDefaultVBLRoutines = -33,        // GetInterruptFunctions (Interrupts.h) failed
  79.     kGDXErrOSSUnableToInstallVBLRoutines = -34,    // InstallInterruptFunctions (Interrupts.h) failed
  80.     kGDXErrOSSUnableToInstallVSLService = -35,    // VSLNewInterruptService (VideoServices.h) failed
  81.     kGDXErrOSSInterruptSourceStillActive = -36,    // Can't dispose of VSL services since interrupts ON
  82.     kGDXErrOSSUnableToDisposeVSLService = -37,    // VSLDisposeInterruptService (VideoServices.h) failed
  83.     kGDXErrUnableToSizeVRAM = -38,                // Failed VRAM sizing
  84.     kGDXErrNoHardwareCursorSet = -39,            // No hardware cursor has been set
  85.     kGDXErrCannotRenderCursorImage = -40,        // Specific cursor image cannot be rendered by hardware
  86.     kGDXErrUnsupportedFunctionality = -41,        // Functionally (such as hw cursor, power saving) not supported
  87.     kGDXErrDriverCannotRun = -42,                // Driver can't (or shouldn't) be run.
  88.  
  89.     kGDXErrPad = 0x7fffffff                        // Pad to avoid warning of dangling ','
  90. };
  91.  
  92.  
  93.  
  94. //
  95. // GammaTableID
  96. //    This abstract data type is used to reference gamma tables.
  97. //    (The typedef is declared in the API, so just the enumerated constants appear here)
  98. //
  99. enum
  100. {
  101.     kGammaTableIDStandard = 2000,                // Mac Standard Gamma
  102.     kGammaTableIDPageWhite = 2001,                // Page-White Gamma
  103.     kGammaTableIDGray = 2002,                    // Mac Gray Gamma
  104.     kGammaTableIDRubik = 2004,                    // Mac RGB Gamma
  105.     kGammaTableIDNTSCPAL = 2005,                // NTSC/PAL Gamma
  106.     kGammaTableIDCSCTFT = 2006                    // Active Matrix Color LCD Gamma
  107. };
  108.  
  109.  
  110.  
  111. //
  112. // DisplayModeID
  113. //    This abstract data type is used to reference display resolutions.
  114. //    The examples of monitors listed do NOT constitute the full list for a given DisplayModeID.  
  115. //    Instead, they are just intended only to be a represetative sample.
  116. //
  117. //    DisplayModeIDs shouldn't change arbitrarily, even though the are completely private to the driver.
  118. //    This is because the DisplayModeID is stored in NVRAM, and it could result in confusion if
  119. //    a ROM based driver interprets the NVRAM items one way, and a subsequent disk based driver 
  120. //    interprets them differently.
  121. //
  122. enum
  123. {
  124.     kDisplay512x384At60HzNTSC = 1,            // NTSC Safe Title
  125.     kDisplay512x384At60Hz = 2,                // Apple's 12" RGB
  126.     kDisplay640x480At50HzPAL = 3,            // PAL Safe Title
  127.     kDisplay640x480At60HzNTSC = 4,            // NTSC Full Frame
  128.     kDisplay640x480At60HzVGA = 5,            // Typical VGA monitor
  129.     kDisplay640x480At67Hz = 6,                // Apple's 13" & 14" RGB
  130.     kDisplay640x870At75Hz = 7,                 // Apple's Full Page Display (Portrait)
  131.     kDisplay768x576At50HzPAL = 8,            // PAL Full Frame
  132.     kDisplay800x600At56HzVGA = 9,            // SVGA    (VESA Standard)
  133.     kDisplay800x600At60HzVGA = 10,            // SVGA    (VESA Standard)
  134.     kDisplay800x600At72HzVGA = 11,            // SVGA    (VESA Standard)
  135.     kDisplay800x600At75HzVGA = 12,            // SVGA at a higher refresh rate
  136.     kDisplay832x624At75Hz = 13,                // Apple's 16" RGB
  137.     kDisplay1024x768At60HzVGA = 14,            // VESA 1K-60Hz
  138.     kDisplay1024x768At72HzVGA = 15,            // 72Hz (So it records well on TV)
  139.     kDisplay1024x768At75HzVGA = 16,            // VESA 1K-75Hz....higher refresh rate
  140.     kDisplay1024x768At75Hz = 17,            // Apple's 19" RGB
  141.     kDisplay1152x870At75Hz = 18,            // Apple's 21" RGB
  142.     kDisplay1280x960At75Hz = 19,            // Square Pixel version of 1280x1024
  143.     kDisplay1280x1024At75Hz = 20,            // 
  144.     kDisplay256x192At60HzNTSCZoom = 21,        // NTSC Safe Title timing, but 1/4 pixels
  145.     kDisplay320x240At50HzPALZoom = 22,        // PAL Safe Title timing, but 1/4 pixels
  146.     kDisplay320x240At60HzNTSCZoom = 23,        // NTSC Full Frame timing, but 1/4 pixels
  147.     kDisplay384x288At50HzPALZoom = 24,        // PAL Full Frame timing, but 1/4 pixels
  148.     
  149.     kOneGreaterThanLastDisplayModeID,                            // Let this value be auto-incremented
  150.     kMaxDisplayModeIDs = kOneGreaterThanLastDisplayModeID - 1    // so this value is always correct.
  151. };
  152.  
  153.  
  154.  
  155. //
  156. // DisplayCode
  157. //    This abstract data type is used to represent what type of display is physically connected to 
  158. //    the frame buffer controller.  It is important to note that NO ATTEMPT should be made to directly
  159. //    map a DisplayCode from raw or exteneded sense codes.
  160. //    All monitors are considered to be RGB, unless explicitly marked otherwise.  
  161. //    The examples of displays listed in the comments represent only a some instances of that type, not
  162. //    necessarily the full set.
  163. //
  164. //    WARNING! since the the DisplayCode is saved into NVRAM (allocated 1 byte of space), NO DisplayCode
  165. //    should be greater than 255.
  166. //
  167. //    Again, just as with DisplayModeIDs, these values should not be arbitrarily changed, thus avoid
  168. //    confusion between ROM based and disk based drivers.
  169. // 
  170. typedef SInt32 DisplayCode;
  171. enum
  172. {
  173.     kDisplayCodeNoDisplay             = 0,            // No display attached
  174.     kDisplayCodeUnknown                = 1,            // A display is present, but it's type is unknown 
  175.     kDisplayCode12Inch                = 2,            // 12" RGB (Rubik)
  176.     kDisplayCodeStandard            = 3,            // 13"/14" RGB or 12" Monochrome
  177.     kDisplayCodePortrait             = 4,            // 15" Portait RGB (Manufactured by Radius)
  178.     kDisplayCodePortraitMono         = 5,            // 15" Portrait Monochrome
  179.     kDisplayCode16Inch                = 6,            // 16" RGB (GoldFish)
  180.     kDisplayCode19Inch                = 7,            // 19" RGB (Third Party)
  181.     kDisplayCode21Inch                = 8,            // 21" RGB (Vesuvio, Radius 21" RGB)
  182.     kDisplayCode21InchMono            = 9,            // 21" Monochrome (Kong, Radius 21" Mono)
  183.     kDisplayCodeVGA                 = 10,            // VGA
  184.     kDisplayCodeNTSC                 = 11,            // NTSC
  185.     kDisplayCodePAL                 = 12,            // PAL
  186.     kDisplayCodeMultiScanBand1        = 13,            // MultiScan Band-1 (12" thru 16" resolutions)
  187.     kDisplayCodeMultiScanBand2        = 14,            // MultiScan Band-3 (13" thru 19" resolutions)
  188.     kDisplayCodeMultiScanBand3        = 15            // MultiScan Band-3 (13" thru 21" resolutions)
  189. };
  190.  
  191.  
  192.  
  193. //
  194. // SenseLine
  195. //    This abstract data type is used to reference the various monitor sense lines used by frame buffer
  196. //    controllers which can implement Apple's Sense Line Protocol.
  197. //
  198. typedef UInt32 SenseLine;
  199. enum
  200. {
  201.     kSenseLineA = 0,            // Corresponds to Monitor Sense Line 2 (pin 10 on a DB-15 connector)
  202.     kSenseLineB = 1,            // Corresponds to Monitor Sense Line 1 (pin 7 on a DB-15 connector)
  203.     kSenseLineC = 2                // Corresponds to Monitor Sense Line 0 (pin 4 on a DB-15 connector)
  204. };
  205.  
  206.  
  207.  
  208. //
  209. // OSSPropertyStorage
  210. //    This abstract data type specifies how the driver can save information.  The information can be
  211. //    NonVolatile (kOSSPropertyAvailableAtBoot, kOSSPropertyAvailableAtDisk) or Volatile.
  212. //    The OSS insulates the rest of the driver from whatever storage mechanism is used by the OS
  213. //
  214. typedef UInt32 OSSPropertyStorage;
  215. enum
  216. {
  217.     kOSSPropertyAvailableAtBoot,
  218.     kOSSPropertyAvailableAtDisk,
  219.     kOSSPropertyVolatile
  220. };
  221.  
  222.  
  223.  
  224. //
  225. // GraphicsPreferred
  226. //    This structure describes the PropertyValue that is needed for the
  227. //    GetPreferredConfiguration and SetPreferredConfiguration calls.  The DisplayCode is saved in
  228. //    addition to the DisplayModeID and the DepthMode since the core looks at the DisplayCode from the
  229. //    previous boot.  Since only 8 bytes of NVRAM are available to store the data, the OSS will map
  230. //    the GraphicsPreferred structure into a GraphicsNonVolatile structure (defined in GraphicsOSS.c)
  231. //
  232. typedef struct GraphicsPreferred GraphicsPreferred;
  233. struct GraphicsPreferred 
  234. {
  235.     DisplayModeID displayModeID;
  236.     DepthMode depthMode;
  237.     DisplayCode displayCode;                // Save the DisplayCode in case user switches monitors
  238. };
  239.  
  240.  
  241. // The PropertyName for the PreferredConfiguration
  242. #define kPreferredConfigurationName "gprf"
  243.  
  244. //
  245. // GraphicsHAL VBL handler prototypes
  246. //    Function definitions for the HALs to handle real vbl's
  247. //
  248. typedef void VBLHandler(void* vblRefCon);
  249. typedef void VBLEnabler(void *vblRefcon);
  250. typedef Boolean VBLDisabler(void *vblRefcon);
  251.  
  252.  
  253.  
  254. //
  255. // DisplayModeIDData
  256. //    All the DisplayModeIDs need to be examined by the Core/OSS for GetNextResolution,
  257. //    GetVideoParamenters and when the OSS compresses the 'gprf' data to be in 8 bytes.
  258. //    This table combines all the information into one table
  259. //
  260. typedef struct DisplayModeIDData DisplayModeIDData;
  261. struct DisplayModeIDData 
  262. {
  263.     DisplayModeID displayModeID;            // The DisplayModeID in question
  264.  
  265.     UInt16 horizontalPixels;                 // GetNextResolution/GetVideoParams data
  266.     UInt16 verticalLines;                    // GetNextResolution/GetVideoParams data
  267.     Fixed refreshRate;                        // GetNextResolution/GetVideoParams data
  268. };
  269.  
  270.  
  271. #endif    // __GRAPHICSPRIV__
  272.